<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        项目信息-拜访记录添加
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <link rel="stylesheet" href="../../../../lib/layui2.0/css/layui.css" media="all">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="../../../../js/xm-select.js"></script>

</head>

<style>
    .layui-form-label {
        width: 150px !important;
    }
</style>

<body>

<div class="x-body" id="app">



    <form class="layui-form layui-form-pane" id="add">
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class=" layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'>*</span>联系人员</label>
                    <div class="layui-input-inline w60">
                        <select name="linkmanId" lay-verify="required" id="select">
                            <option value=""></option>

                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'>*</span>沟通内容</label>
                    <div class="layui-input-inline w60">
                        <textarea name="operationContent" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'>*</span>下次拜访日期</label>
                    <div class="layui-input-inline w60">
                        <input  autocomplete="off"  class="layui-input" placeholder="截止日" name="nextTime" id="end">
                    </div>
                </div>
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label"> <span class='x-red'>*</span>图片信息</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input  autocomplete="off"  type="file" ref="pictureOfReceipt" @change="getFile($event,'pictureOfReceipt')"-->
<!--                               name="picUrl"-->
<!--                               placeholder="图片信息" class="layui-input" style="display: none">-->

<!--                        <img style="width: 100px"-->
<!--                             v-if="billing.pictureOfReceipt != null && billing.pictureOfReceipt != ''"-->
<!--                             :src="bindSrcPictureOfReceipt"-->
<!--                             alt="xx" @click="uploadPictureOfReceipt">-->
<!--                        <img style="width: 100px"-->
<!--                             v-if="billing.pictureOfReceipt == null || billing.pictureOfReceipt == ''"-->
<!--                             src="../../../../images/upload.png"-->
<!--                             alt="xx" @click="uploadPictureOfReceipt">-->
<!--                    </div>-->
<!--                </div>-->




                <div style="text-align: center" class="layui-form-item">
                    <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                        增加
                    </button>
                </div>
                <!--</form>-->


                <div style="height:20px;"></div>
            </div>


        </div>

    </form>

</div>
<script type="text/javascript" src="../../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script src="../../../../lib/layui/layui2.5.7.js" charset="utf-8"></script>
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="../../../../js/vue.min.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script>
    layui.use(['element', 'layer', 'form', 'laydate'], function () {
        $ = layui.jquery;//jquery
        element = layui.element;//面包导航
        layer = layui.layer;//弹出层
        laydate = layui.laydate;//日期插件
        form = layui.form;
        okLoading.close($);
    })

</script>
<script>

    var recordId = getQueryVariable("recordId");




    layui.use(['laydate', 'form', 'layer'],
        function () {
            var form = layui.form;
            var layer = layui.layer;
            var laydate = layui.laydate;
            getBusiness();
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#end' //指定元素
            });


            //监听审批提交
            form.on('submit(sub)',
                function (data) {
                    let form = data.field;
                    form.userId=$userId;
                    form.projectId=recordId;
                    form.logType=2;
                    form.operatorId=$userId;
                    let request = {
                        url: 'xa/projectLog/addVisitRecords',
                        data: form,
                        method: "post",
                    };
                    sendRequest(request, (data) => {
                        if (data.code === 0) {
                            layer.alert("操作成功", {
                                    icon: 6
                                },
                                function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    parent.location.reload();

                                });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            })
                        }
                    });
                    return false;
                });


        });

    function getBusiness(){

        $.ajax({
            type:"get",
            url:baseHead + "xa/projectLinkman/findProjectLinkman",
            data:{
                userId :$userId,
                businessTypeId:0,
                projectId:recordId
            },
            headers: {
                "token": $token,
            },
            success:function(res){
                if(res.code == 0){
                    console.log(res);
                    for(var i =0;i < res.data.length;i++){
                        $("#select").append("<option value=\""+res.data[i].id+"\" selected>"+res.data[i].linkmanName+"</option>");
                    }
                    //重新渲染
                    layui.form.render("select");
                }else{
                    layer.msg(res.message);
                }
            }
        });
    };

</script>

</body>

</html>
